package com.work.account2.controller;

import com.work.account2.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

@RestController
public class AccountController {

    @Autowired
    private AccountService accountService;

    @RequestMapping("/reduce")
    public Boolean reduce(String userId, BigDecimal money) {
        accountService.reduce(userId, money);

        return true;
    }

    /**
     * 提供 TCC 方式
     * @param userId
     * @param orderMoney
     * @return
     */
    @RequestMapping("/tcc/reduce")
    public Boolean tccReduce(String userId, BigDecimal orderMoney) {
        accountService.tccReduce(userId, orderMoney);
        return true;
    }
}
